package com.xiaoshuidi.cloud.module.member.mapper;


import com.xiaoshuidi.cloud.framework.mybatis.core.mapper.BaseMapperX;
import com.xiaoshuidi.cloud.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.xiaoshuidi.cloud.module.member.pojo.user.MemberAddress;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;


@Mapper
public interface AddressMapper extends BaseMapperX<MemberAddress> {

    default MemberAddress selectByIdAndUserId(Long id, Long userId) {
        return selectOne(MemberAddress::getId, id, MemberAddress::getUserId, userId);
    }

    default List<MemberAddress> selectListByUserIdAndDefaulted(Long userId, Boolean defaulted) {
        return selectList(new LambdaQueryWrapperX<MemberAddress>().eq(MemberAddress::getUserId, userId)
                .eqIfPresent(MemberAddress::getDefaulted, defaulted));
    }

}
